using MicroMsg.Storage;
using MicroMsg.UI.Util;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace MicroMsg.UI.UserContrl
{
	public class GroupCardItem : UserControl
	{
		public delegate void ListItemClick(object sender, object object_0);
		public static DependencyProperty ListItemProperty = DependencyProperty.Register("ItemObject", typeof(Contact), typeof(GroupCardItem), new PropertyMetadata(null, new PropertyChangedCallback(GroupCardItem.OnItemPropertyChanged)));
		public static long sLTimeComsume = 0L;
		public static int sNCount = 0;
		internal Button btnLayoutRoot;
		internal Border ImgBackGround;
		internal Image ImgHead;
		internal EmojiText txBkTitle;
		internal EmojiText txBkSignature;
		private bool _contentLoaded;
		public event GroupCardItem.ListItemClick ItemClick;
		public Contact ItemObject
		{
			get
			{
				return (Contact)base.GetValue(GroupCardItem.ListItemProperty);
			}
			set
			{
				base.SetValue(GroupCardItem.ListItemProperty, value);
			}
		}
		private static void OnItemPropertyChanged(DependencyObject dependencyObject_0, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			if (dependencyPropertyChangedEventArgs_0.get_Property() == GroupCardItem.ListItemProperty)
			{
				(dependencyObject_0 as GroupCardItem).OnListItemPropertyChanged(dependencyPropertyChangedEventArgs_0);
			}
		}
		private void OnListItemPropertyChanged(DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			try
			{
				this.RefreshItem(dependencyPropertyChangedEventArgs_0.get_NewValue() as Contact);
			}
			catch (Exception ex)
			{
				ex.ToString();
			}
		}
		public GroupCardItem()
		{
			this.InitializeComponent();
		}
		private void btnLayoutRoot_Click(object sender, RoutedEventArgs e)
		{
			if (this.ItemClick != null)
			{
				this.ItemClick(this, this.ItemObject);
			}
		}
		private void RefreshItem(Contact item)
		{
			if (item == null)
			{
				return;
			}
			new ImageSourceConverter();
		}
		private void refreshTextInfo(Contact item)
		{
			if (this.ItemObject.strRemark != null && this.ItemObject.strRemark.get_Length() != 0)
			{
				this.txBkTitle.Text = this.ItemObject.strRemark;
			}
			else
			{
				if (!ToolFunction.isBlankString(this.ItemObject.strNickName))
				{
					this.txBkTitle.Text = this.ItemObject.strNickName;
				}
				else
				{
					this.txBkTitle.Text = this.ItemObject.strUsrName;
				}
			}
			this.txBkSignature.Text = this.ItemObject.strSignature;
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/UI/Contact/GroupCardItem.xaml", 2));
			this.btnLayoutRoot = (Button)base.FindName("btnLayoutRoot");
			this.ImgBackGround = (Border)base.FindName("ImgBackGround");
			this.ImgHead = (Image)base.FindName("ImgHead");
			this.txBkTitle = (EmojiText)base.FindName("txBkTitle");
			this.txBkSignature = (EmojiText)base.FindName("txBkSignature");
		}
	}
}
